const text = 'hello world' //声明常量

let name1 = 'jack' //声明变量


const num = 9;

const str = '123456'

const bl = false;

const obj = {
    name: 'jack',
    age: 18,
}

const arr = [1, 2, 3, 6];



axios

function funName(params) {//函数内可以访问到函数外的变量
    console.log(text + '-' + name1);
    console.log(params);
    // console.log(params['name'],params['age']);
    // console.log(params.age,params.name);

    console.log(params[0], params[3], params.length, params[params.length - 1]);
}

//funName(obj);
funName(arr);
function handleClick(e) {
    console.log(e);
    e.target.style.color = 'red';
    const circleElem = document.getElementById('circleId');

    console.log(circleElem);
    //circleElem.style.display='block'
    if (circleElem.classList.contains('circle-show')) {
        circleElem.className = 'circle';

    } else {
        circleElem.classList.add('circle-show');
    }

}
const getUserInfo = function (params) {
    console.log('getUersInfo')
    axios.get('http://127.0.0.1:3000/user')
        .then((res) => {
            console.log(res.data);
            document.getElementById('name').innerText = res.data.name;//获取数据在网面上显示
            document.getElementById('age').innerText = res.data.age + '岁';
            document.getElementById('avatar').src= 'data:image/*;base64,'+res.data.avatar
        })
        .catch((err) => { console.error(err) })
}

const buttonItem = document.getElementById('button')
buttonItem.addEventListener('click', getUserInfo);
